﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace WindowsGame1
{
    class Monster : BaseObject
    {
        public Monster()
        {
            m_ObjectType = OBJ_TYPE.OBJ_ENEMY;

            m_Position = new Vector2(500, 100);
            m_AnimOrigin = new Vector2(0, 0);
            m_nMaxFrame = 1;
        }

        override public void Update(float deltaT, KeyboardState LastKeyState)
        {
            m_Position.Y += m_Velocity.Y * deltaT;
            m_Position.X += m_Velocity.X * deltaT;

            if (m_Position.Y > 600 - 1)
            {
                m_Position.Y = 600;
                m_Velocity.Y = 0.0f;
            }
            else
            {
                m_Velocity.Y += 9.81f;
            }

            m_fFrame += deltaT * ((m_Velocity.X > 0.0f) ? m_Velocity.X : -m_Velocity.X) / 25.0f;
            if (m_fFrame >= m_nMaxFrame)
                m_fFrame = 0;
        }

        override public void Render(SpriteBatch spriteBatch, Camera cam)
        {
            spriteBatch.Draw(m_Texture, new Rectangle((int)((m_Position.X - cam.m_Position.X) * cam.m_fZoom), (int)((m_Position.Y - cam.m_Position.Y) * cam.m_fZoom), (int)(128 * cam.m_fZoom), (int)(128 * cam.m_fZoom)), new Rectangle(128 * (int)m_fFrame + (int)m_AnimOrigin.X, (int)m_AnimOrigin.Y, 128, 128), Color.White, 0.0f, new Vector2(64, 128), m_Direction, 0.0f);
        }
    }
}
